<template>
  <el-main style="width: 100%">
    <el-row class="margin-bottom-10">
      <el-col :span="20" class="mb10">
        <span class="text-size">工程名称:</span>
        <span class="text-size">11</span>
      </el-col>
      <el-col :span="20">
        <span class="text-size">委托单编号:</span>
        <span class="text-size">11</span>
      </el-col>
    </el-row>
    <el-row class="margin-bottom-10">
      <el-col :span="20">
        <el-form :inline="true">
          <el-form-item label="文件名称" style="margin-bottom: 10px;">
            <el-input type="input" v-model="name1" style="width:600px"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-row class="margin-bottom-10">
      <el-col :span="5">
        <el-input type="input" v-model="filename"></el-input>
      </el-col>
      <el-col :span="5">
        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          multiple
          :limit="3"
          :on-exceed="handleExceed"
          :file-list="fileList"
        >
          <el-button size="small" style="margin-left:10px">浏览</el-button>
          <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div> -->
        </el-upload>
      </el-col>
      <el-col :span="5">
        <span
          class="text-size"
          style="color:#1176FF;cursor: pointer;"
          @click="downloadFile('https://example.com/sample.pdf', '委托单.pdf')"
        >附表模版下载</span>
      </el-col>
    </el-row>
    <el-row class="margin-bottom-10">
      <el-col style="text-align: center;margin-top:15px" :span="15">
        <el-button type="primary" @click="submitbtn">确定</el-button>
        <el-button @click="goback">返回</el-button>
      </el-col>
    </el-row>
  </el-main>
</template>

<script>
export default {
  data() {
    return {
      name1: "",
      filename: "",
      fileList: []
    };
  },
  methods: {
    downloadFile(url, filename) {
      const link = document.createElement("a");
      link.href = url;
      link.download = filename || "download";
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${
          files.length
        } 个文件，共选择了 ${files.length + fileList.length} 个文件`
      );
    },
    submitbtn() {},
    goback() {
      this.$router.back();
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    }
  }
};
</script>

<style lang="scss" scoped>
.text-size {
  font-size: 14px;
  color: #606266;
}
.margin-bottom-10 {
  margin-bottom: 10px;
}
</style>